#pragma once
#include "stdafx.h"
#include <Eigen/Eigen>
#include <iostream>
#include <vector>

using namespace Eigen;
using namespace std;

//Template to represent a single instance of a grid element
//element is a pointer to the x number of elements defining the gridelement (2d:4,3d:6)
template <class T>
class GridElement{
	int size;
	VectorXd color;
	std::vector<std::vector<VectorXd>> triangles;
	std::vector<T> element;
	std::vector<Eigen::Vector2i> line; //describes a line drawn between the element ridgepoints, e.g. a line between [0].x/y and [1].x/y etc.. //Only for 2d
public:
	GridElement(){
	}

	GridElement(T elements[],int s){
		//this->line.reserve(4); //reserve enough space for 4 lines
		this->size = s;
		this->element.resize(size);
		for(int i = 0;i<size;i++){
			this->element[i] = elements[i];
		}
	}

	~GridElement(){}
	
	/*void setElement(int i,T &e){
		this->element[i] = e;
	}*/

	T getElement(int e){
		return element[e];
	}

	void setColor(VectorXd c){
		this->color = c;
	}

	VectorXd getColor(){
		return this->color;
	}

	void addTriangle(std::vector<VectorXd> t){
		this->triangles.push_back(t);
	}

	std::vector<std::vector<VectorXd>> getTriangles(){
		return this->triangles;
	}

	int getSize(){
		return this->size;
	}

	void addLine(Eigen::Vector2i l){
		this->line.push_back(l);
	}

	std::vector<Eigen::Vector2i> getLines(){
		return this->line;
	}

};

